home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / boxingbag.lua < prev    next >
Text File  |  2004-01-29  |  1KB  |  44 lines

  1. -- boxing bag state machine
  2.  
  3. beginStateMachine()
  4.  
  5.     onMsg("buildMenu", function(msg)
  6.         if (repairMenu()) then return end
  7.         
  8.         -- build the pie menu
  9.         clearPieMenu();
  10.         local button;
  11.         button = addPieMenuButton("pm_box", "box");
  12.         button.addDescription(ACTIVITY, "box");
  13.         -- button.addIcon("guiIconSpass");
  14.  
  15.     end )
  16.  
  17.     -- 
  18.     onMsg("box", function(msg)
  19.         -- get character who initiated this action
  20.         local character = getStateObjectFromID(msg.sender);
  21.         -- walk to the closest action point
  22.         local actionPoint = character.getClosestFreeActionPoint(character, this, {"box1", "box2", "box3"});
  23.         -- get the walk state object
  24.         local wso = character.walkSO;
  25.         if (actionPoint) then
  26.             if (wso.walkToActionPoint(actionPoint)) then
  27.                 -- create state machine contexts
  28.                 local wsoContext = StateMachineContext();
  29.                 -- store the action point
  30.                 wsoContext.storeData("actionPointName", actionPoint.getName());
  31.                 
  32.                 wso.queueStateMachine("boxingbagChar.box", this, wsoContext);
  33.             else
  34.                 print("no path found");
  35.                 instantAbort(character, EMOTICON_NOPATH, "emoThink");
  36.             end
  37.         else
  38.             print("no action point found");
  39.             instantAbort(character, EMOTICON_CANNOT, "emoThink")
  40.         end
  41.     end )
  42.             
  43. endStateMachine()
  44.